﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="murdType", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MurdType))]
    public class MurdTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMurdType clazz;
        
        public MurdTypeSerializer(IMurdType clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("lugeja");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Lugeja))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("nimetaja");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Nimetaja))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="lugeja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>murdType>lugeja");
                }
                clazz.Lugeja = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("lugeja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>murdType>lugeja", Reader.LocalName);
            }
            if (Reader.LocalName=="nimetaja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>murdType>nimetaja");
                }
                clazz.Nimetaja = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("nimetaja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>murdType>nimetaja", Reader.LocalName);
            }
        }
    }
}
